/*
-----------------------------------------------
Quick table of Summary Stats- Spam survey

Shobitha Cherian - Louis-Mael JEAN
12 June 2020
-----------------------------------------------
*/ 

*Paths*
clear all 
set more off 

global today: display %tdCCYYNNDD date(c(current_date), "DMY")
di $today


loc path_LM = "/Users/louis-maeljean/Dropbox (MIT)/West Bengal Information Campaign/AER_I/for_submission"
loc path = "`path_LM'" 		//other users should change this

cd "`path'"


*Import 

use "`path'/data/spam_survey_clean_20200612.dta", clear 

*The below variables were created by winsorizing the variables num_phonecalls, sd, masks and handwashing at 95%-ile level 
label var Wnum_phonecalls "Outgoing phone calls made"
label var Wsd "Social Distancing messages received"
label var Wmasks "Mask usage messages received"
label var Whandwashing "Messages received on washing hands"

foreach var of varlist ///
Wnum_phonecalls Wsd Wmasks Whandwashing {
summ `var' 
loc `var'mean = string(r(mean), "%9.3f") 
loc `var'sd = string(r(sd), "%9.3f")
loc `var'N = string(r(N), "%9.0f")
}

cap file close file1
		file open file1 using "output/Tables/TableA1_Spam_summstats.tex", write replace 
		file write file1 "\begin{tabular}{|l|c|c|c|}" _n
		file write file1 "\hline" _n
		file write file1 "& Mean & SD & N  \\" _n 
		file write file1 "\hline" _n
		foreach var of varlist Wnum_phonecalls Wsd Wmasks Whandwashing {
		loc labels: variable label `var' 
		file write file1 "`labels' & ``var'mean' & ``var'sd' & ``var'N' \\" _n 
		}
		file write file1 "\hline" _n
		file write file1 "\end{tabular}" _n
		file write file1 "%table notes: Respondents were asked the total number of outgoing phone calls they had made,"_n
		file write file1 "%and the number of messages on social distancing," _n
		file write file1 "%washing hands, and using masks they had heard/received in the last 2 days." _n
file close file1



**************************************
** END 
**************************************

